import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/Login/index.vue'
import Home from '@/views/Home/index.vue'
import Layout from '@/views/Layout/index.vue'
import User from '@/views/User/index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    redirect: '/layout/home' //路由重定向，默认一登录就在登录页面
  },
  {
    path:'/login',
    component:Login,
  },
  {
    path:'/layout',
    component:Layout,
    children:[
      {
        path:'home',//子路由前面不能加/
        component:Home,
      },
      {
        path:'user',
        component:User,
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
